$(function(){
    // 页面滚动时固定导航栏
    window.onscroll = function () {
        //每次滚动的时候先去获取当前页面的卷曲距离
        var scrl = scroll();
        if (scrl.top > 426) {
            $(".header").addClass("nav_fixed");
            //让主体部分加间距
            $("#main_part").css({
                "margin-top": 80
            })
        } else {
            $(".header").removeClass("nav_fixed");
            $("#main_part").css({
                "margin-top": 0
            })
        }
        if (scrl.top > 600) {
            $("#J_gotoTop").css("right", 35)

        } else {
            $("#J_gotoTop").css("right", -100);

        }
		try {
			setTimeout(function(){
				$("#customer_service_qq").hide();
			},3000)
		} catch(e){}
        
    };

    function scroll() {
        return {
            top: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0,
            left: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0
        };
    }

    // 回到顶部
    $("#J_gotoTop").on("click", function () {
        $("body,html").stop().animate({scrollTop:0},500);
    })

    $("#jys_navbar .link").on("click", function () {
        $(this).addClass("active").siblings(".link").removeClass("active");
    })

    // 显示微信二维码
    $(".weixin_icon").on("mouseenter",function(){
        $(".wx_ewm_img").show();
        $("#customer_service_qq").hide();
    })
    $(".weixin_icon").on("mouseout",function(){
        $(".wx_ewm_img").fadeOut(400);
    }) 

    // 显示QQ客服       
    $(".social_contact .qq_service_box").on("mouseenter",function(){
        $("#customer_service_qq").show();
    })
    $(".close_qq_btn").on("click",function(){
        $("#customer_service_qq").hide();
    })
	
	// 点击其它地方隐藏客服咨询框
	$(document).on("click.hideselect", function(e){
		var e = e || window.event; //浏览器兼容性 
		var elem = e.target || e.srcElement; 
		while (elem) { //循环判断至跟节点，除了类名为select_area隐藏提示的ul元素
			if ( elem.className && (elem.className.indexOf('hover-drop')) >= 0) { 
				return; 
			}
			if ( elem.className && (elem.className.indexOf('qq-drop-box')) >= 0) { 
				return; 
			}
			if ( elem.className && (elem.className.indexOf('zx-div')) >= 0) { 
				return; 
			}
			$("#customer_service_qq").hide(); 
			elem = elem.parentNode; 
		}
	});
})